<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="./template.xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:c="http://java.sun.com/jsp/jstl/core"
                xmlns:f="http://java.sun.com/jsf/core">

    <ui:define name="top">
        #{itemCTRL.item.name}
    </ui:define>

    <ui:define name="left">
    </ui:define>

    <ui:define name="body">
        <h:panelGrid columns="2">
        
        <h:form id="viewItem">
            <h:panelGrid width="50%" columns="2" border="1">
                <h:outputLabel value="Name:"/>
                <h:outputText value="#{itemCTRL.item.name}"/>
                
                <h:outputLabel value="Manufacturer:"/>
                <h:outputText value="#{itemCTRL.item.manufacturer}"/>
                
                <h:outputLabel value="Stock:"/>
                <h:outputText value="#{itemCTRL.item.stock}"/>
                
                <h:outputLabel value="Price:"/>
                <h:outputText value="#{itemCTRL.item.price}"/>
                
                <h:outputLabel value="Description:"/>
                <h:outputText value="#{itemCTRL.item.descrip}"/>
                
                <c:forEach items="#{itemCTRL.item.attributeValues}" var="items">
                    <h:outputLabel value="#{items.attribute.name}"/>
                    <h:outputText value="#{items.value}"/>
                </c:forEach>
            </h:panelGrid>
            <h:panelGrid columns="3" border="0">
                <h:outputLabel for="quantity" value="Quantity:"/>
                <h:inputText
                    size="3"
                    onclick="document.getElementById('viewItem:quantity').value=''"
                    id="quantity" 
                    value="#{cartCTRL.newItemQuantity}">
                    <f:validateLongRange minimum="0"/>
                </h:inputText>
                <h:commandButton
                    value="Add to Cart"
                    action="#{cartCTRL.addToCart}"/>
                
                <h:link outcome="CheckOut" value="Checkout"/>
                <h:panelGroup/>
                <h:link outcome="CustomerMain" value="Continue Shopping"/>
            </h:panelGrid>
        </h:form>
            <h:graphicImage width="320" height="240" url="/image/items/#{itemCTRL.item.id}.jpg"/>
        </h:panelGrid>
    </ui:define>

</ui:composition>
